<!DOCTYPE html>
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
  <meta name="description" content="刘清政">
  <meta name="keyword" content="hexo-theme">
  
    <link rel="shortcut icon" href="/css/images/logo.png">
  
  <title>
    
      python/路飞项目/2-git笔记/1-git | Justin-刘清政的博客
    
  </title>
  <link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
  <link href="//cdnjs.cloudflare.com/ajax/libs/nprogress/0.2.0/nprogress.min.css" rel="stylesheet">
  <link href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/tomorrow.min.css" rel="stylesheet">
  
<link rel="stylesheet" href="/css/style.css">

  
    
<link rel="stylesheet" href="/css/plugins/gitment.css">

  
  <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/geopattern/1.2.3/js/geopattern.min.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/nprogress/0.2.0/nprogress.min.js"></script>
  
    
<script src="/js/qrious.js"></script>

  
  
    
<script src="/js/gitment.js"></script>

  
  

  
<meta name="generator" content="Hexo 4.2.0"></head>
<div class="wechat-share">
  <img src="/css/images/logo.png" />
</div>

  <body>
    <header class="header fixed-header">
  <div class="header-container">
    <a class="home-link" href="/">
      <div class="logo"></div>
      <span>Justin-刘清政的博客</span>
    </a>
    <ul class="right-list">
      
        <li class="list-item">
          
            <a href="/" class="item-link">主页</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/tags/" class="item-link">标签</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/archives/" class="item-link">归档</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/about/" class="item-link">关于我</a>
          
        </li>
      
    </ul>
    <div class="menu">
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </div>
    <div class="menu-mask">
      <ul class="menu-list">
        
          <li class="menu-item">
            
              <a href="/" class="menu-link">主页</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/tags/" class="menu-link">标签</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/archives/" class="menu-link">归档</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/about/" class="menu-link">关于我</a>
            
          </li>
        
      </ul>
    </div>
  </div>
</header>

    <div id="article-banner">
  <h2>python/路飞项目/2-git笔记/1-git</h2>



  <p class="post-date">2020-02-29</p>
    <!-- 不蒜子统计 -->
    <span id="busuanzi_container_page_pv" style='display:none' class="">
        <i class="icon-smile icon"></i> 阅读数：<span id="busuanzi_value_page_pv"></span>次
    </span>
  <div class="arrow-down">
    <a href="javascript:;"></a>
  </div>
</div>
<main class="app-body flex-box">
  <!-- Article START -->
  <article class="post-article">
    <section class="markdown-content"><h2 id="版本控制器"><a href="#版本控制器" class="headerlink" title="版本控制器"></a>版本控制器</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">完成 协同开发 项目，帮助程序员整合代码</span></span><br><span class="line"><span class="string">	i）帮助开发者合并开发的代码</span></span><br><span class="line"><span class="string">	ii）如果出现冲突代码的合并，会提示后提交合并代码的开发者，让其解决冲突</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">软件：SVN 、 GIT（都是同一个人的个人项目）</span></span><br><span class="line"><span class="string">	github、gitee（两个采用git版本控制器管理代码的公共平台）</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">git：集群化、多分支</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>



<h2 id="git"><a href="#git" class="headerlink" title="git"></a>git</h2><h4 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">什么是git：版本控制器 - 控制的对象是开发的项目代码</span></span><br><span class="line"><span class="string">代码开发时间轴：需求1 =&gt; 版本库1 ==&gt; 需求2 =&gt; 版本库2 =&gt; 版本库3(版本库1) =&gt; 版本库4(版本库2) </span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>

<h4 id="git与svn比较"><a href="#git与svn比较" class="headerlink" title="git与svn比较"></a>git与svn比较</h4><p><img src="https://tva1.sinaimg.cn/large/007S8ZIlgy1ggqvsye2khj30kj0a6mx3.jpg" alt=""></p>
<p><img src="https://tva1.sinaimg.cn/large/007S8ZIlgy1ggqvt8t61hj30m10da3yk.jpg" alt=""></p>
<h4 id="git的工作流程"><a href="#git的工作流程" class="headerlink" title="git的工作流程"></a>git的工作流程</h4><p><img src="https://tva1.sinaimg.cn/large/007S8ZIlgy1ggqvthch46j30wv0ejmy1.jpg" alt=""></p>
<h4 id="版本库间的通信"><a href="#版本库间的通信" class="headerlink" title="版本库间的通信"></a>版本库间的通信</h4><p><img src="https://tva1.sinaimg.cn/large/007S8ZIlgy1ggqvtl4jlnj30wc08naad.jpg" alt=""></p>
<h4 id="git分支管理"><a href="#git分支管理" class="headerlink" title="git分支管理"></a>git分支管理</h4><p><img src="https://tva1.sinaimg.cn/large/007S8ZIlgy1ggqvtp3d2zj310v0bmq3h.jpg" alt=""></p>
<h2 id="git使用"><a href="#git使用" class="headerlink" title="git使用"></a>git使用</h2><h3 id="流程（核心总结）"><a href="#流程（核心总结）" class="headerlink" title="流程（核心总结）"></a>流程（核心总结）</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">1）有红色信息(工作区有内容)，就执行 add </span></span><br><span class="line"><span class="string">2）全绿信息(内容全部在暂存区)，才执行 commit</span></span><br><span class="line"><span class="string">3）只有被版本库控制的代码，才能被监听，所以可以回滚到任何一个版本</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>



<h4 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 1.下载对应版本：https://git-scm.com/download</span></span><br><span class="line"><span class="comment"># 2.安装git：在选取安装路径的下一步选取 Use a TrueType font in all console windows 选项</span></span><br></pre></td></tr></table></figure>



<h4 id="基础命令"><a href="#基础命令" class="headerlink" title="基础命令"></a>基础命令</h4><h5 id="将已有的文件夹-初始化为git仓库"><a href="#将已有的文件夹-初始化为git仓库" class="headerlink" title="将已有的文件夹 - 初始化为git仓库"></a>将已有的文件夹 - 初始化为git仓库</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">&gt;: cd 目标文件夹内部</span></span><br><span class="line"><span class="string">&gt;: git init</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>

<h5 id="在指定目录下-初始化git仓库"><a href="#在指定目录下-初始化git仓库" class="headerlink" title="在指定目录下 - 初始化git仓库"></a>在指定目录下 - 初始化git仓库</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">&gt;: cd 目标目录</span></span><br><span class="line"><span class="string">&gt;: git init 仓库名</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>

<h5 id="在仓库目录终端下-设置全局用户"><a href="#在仓库目录终端下-设置全局用户" class="headerlink" title="在仓库目录终端下 - 设置全局用户"></a>在仓库目录终端下 - 设置全局用户</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">&gt;: git config --global user.name '用户名'</span></span><br><span class="line"><span class="string">&gt;: git config --global user.email '用户邮箱'</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">注：在全局文件 C:\Users\用户文件夹\.gitconfig新建用户信息，在所有仓库下都可以使用</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>

<h5 id="在仓库目录终端下-设置局部用户"><a href="#在仓库目录终端下-设置局部用户" class="headerlink" title="在仓库目录终端下 - 设置局部用户"></a>在仓库目录终端下 - 设置局部用户</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">&gt;: git config user.name '用户名'</span></span><br><span class="line"><span class="string">	-- 用户名</span></span><br><span class="line"><span class="string">&gt;: git config user.email '用户邮箱'</span></span><br><span class="line"><span class="string">	-- 用户邮箱</span></span><br><span class="line"><span class="string">	</span></span><br><span class="line"><span class="string">注：在当前仓库下的config新建用户信息，只能在当前仓库下使用</span></span><br><span class="line"><span class="string">注：一个仓库有局部用户，优先使用局部用户，没有配置再找全局用户</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>

<h5 id="查看仓库状态"><a href="#查看仓库状态" class="headerlink" title="查看仓库状态"></a>查看仓库状态</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string"># 当仓库中有文件增加、删除、修改，都可以在仓库状态中查看</span></span><br><span class="line"><span class="string">&gt;: git status  </span></span><br><span class="line"><span class="string">	-- 查看仓库状态</span></span><br><span class="line"><span class="string">&gt;: git status -s  </span></span><br><span class="line"><span class="string">	-- 查看仓库状态的简约显示</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>

<h5 id="工作区操作"><a href="#工作区操作" class="headerlink" title="工作区操作"></a>工作区操作</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 通过任何方式完成的文件删与改</span></span><br><span class="line"><span class="comment"># 空文件夹不会被git记录</span></span><br></pre></td></tr></table></figure>

<h5 id="撤销工作区操作：改、删（了解）"><a href="#撤销工作区操作：改、删（了解）" class="headerlink" title="撤销工作区操作：改、删（了解）"></a>撤销工作区操作：改、删（了解）</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">&gt;: git checkout .</span></span><br><span class="line"><span class="string">	-- 撤销所有暂存区的提交</span></span><br><span class="line"><span class="string">&gt;: git checkout 文件名</span></span><br><span class="line"><span class="string">	-- 撤销某一文件的暂存区提交</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>

<h5 id="工作区内容提交到暂存区"><a href="#工作区内容提交到暂存区" class="headerlink" title="工作区内容提交到暂存区"></a>工作区内容提交到暂存区</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">&gt;: git add .  </span></span><br><span class="line"><span class="string">	-- 添加项目中所有文件</span></span><br><span class="line"><span class="string">&gt;: git add 文件名  </span></span><br><span class="line"><span class="string">	-- 添加指定文件</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>

<h5 id="撤销暂存区提交：add的逆运算（很少使用）"><a href="#撤销暂存区提交：add的逆运算（很少使用）" class="headerlink" title="撤销暂存区提交：add的逆运算（很少使用）"></a>撤销暂存区提交：add的逆运算（很少使用）</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">&gt;: git reset HEAD .</span></span><br><span class="line"><span class="string">	-- 撤销所有暂存区的提交</span></span><br><span class="line"><span class="string">&gt;: git reset 文件名</span></span><br><span class="line"><span class="string">	-- 撤销某一文件的暂存区提交</span></span><br><span class="line"><span class="string">&gt;: git reset .</span></span><br><span class="line"><span class="string">	-- 撤销所有暂存区的提交</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>

<h5 id="提交暂存区内容到版本库"><a href="#提交暂存区内容到版本库" class="headerlink" title="提交暂存区内容到版本库"></a>提交暂存区内容到版本库</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&gt;: git commit -m &quot;版本描述信息&quot;</span><br></pre></td></tr></table></figure>

<h5 id="撤销版本库提交：commit的逆运算"><a href="#撤销版本库提交：commit的逆运算" class="headerlink" title="撤销版本库提交：commit的逆运算"></a>撤销版本库提交：commit的逆运算</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">回滚暂存区已经提交到版本库的操作：</span></span><br><span class="line"><span class="string">    查看历史版本：</span></span><br><span class="line"><span class="string">        &gt;: git log</span></span><br><span class="line"><span class="string">        &gt;: git reflog</span></span><br><span class="line"><span class="string">    查看时间点之前|之后的日志：</span></span><br><span class="line"><span class="string">        &gt;: git log --after 2018-6-1</span></span><br><span class="line"><span class="string">        &gt;: git log --before 2018-6-1</span></span><br><span class="line"><span class="string">        &gt;: git reflog --after 2018-6-1</span></span><br><span class="line"><span class="string">        &gt;: git reflog --before 2018-6-1</span></span><br><span class="line"><span class="string">    查看指定开发者日志</span></span><br><span class="line"><span class="string">        &gt;: git log --author author_name</span></span><br><span class="line"><span class="string">        &gt;: git reflog --author author_name</span></span><br><span class="line"><span class="string">    回滚到指定版本：</span></span><br><span class="line"><span class="string">        回滚到上一个版本：</span></span><br><span class="line"><span class="string">            &gt;: git reset --hard HEAD^</span></span><br><span class="line"><span class="string">            &gt;: git reset --hard HEAD~</span></span><br><span class="line"><span class="string">        回滚到上三个版本：</span></span><br><span class="line"><span class="string">            &gt;: git reset --hard HEAD^^^</span></span><br><span class="line"><span class="string">            &gt;: git reset --hard HEAD~3</span></span><br><span class="line"><span class="string">        回滚到指定版本号的版本：</span></span><br><span class="line"><span class="string">            &gt;: git reset --hard 版本号 (重点)</span></span><br><span class="line"><span class="string">            &gt;: eg: git reset --hard 35cb292</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>

<h3 id="过滤文件"><a href="#过滤文件" class="headerlink" title="过滤文件"></a>过滤文件</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># .gitignore 文件</span></span><br><span class="line"><span class="comment"># 1）在仓库根目录下创建该文件</span></span><br><span class="line"><span class="comment"># 2）文件与文件夹均可以被过滤</span></span><br><span class="line"><span class="comment"># 3）文件过滤语法</span></span><br><span class="line"></span><br><span class="line"><span class="string">""" 过滤文件内容</span></span><br><span class="line"><span class="string">文件或文件夹名：代表所有目录下的同名文件或文件夹都被过滤</span></span><br><span class="line"><span class="string">/文件或文件夹名：代表仓库根目录下的文件或文件夹被过滤</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">eg：</span></span><br><span class="line"><span class="string">a.txt：项目中所有a.txt文件和文件夹都会被过滤</span></span><br><span class="line"><span class="string">/a.txt：项目中只有根目录下a.txt文件和文件夹会被过滤</span></span><br><span class="line"><span class="string">/b/a.txt：项目中只有根目录下的b文件夹下的a.txt文件和文件夹会被过滤</span></span><br><span class="line"><span class="string">*x*：名字中有一个x的都会被过滤（*代表0~n个任意字符）</span></span><br><span class="line"><span class="string">空文件夹不会被提交，空包会被提交，包可以被提交（包中有一个init空文件）</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>





<h3 id="多分支开发"><a href="#多分支开发" class="headerlink" title="多分支开发"></a>多分支开发</h3><h5 id="分支操作"><a href="#分支操作" class="headerlink" title="分支操作"></a>分支操作</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">1.创建分支</span></span><br><span class="line"><span class="string">&gt;: git branch 分支名</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">2.查看分支</span></span><br><span class="line"><span class="string">&gt;: git branch</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">3.切换分支</span></span><br><span class="line"><span class="string">&gt;: git checkout 分支名</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">4.创建并切换到分支</span></span><br><span class="line"><span class="string">&gt;: git checkout -b 分支名</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">5.删除分支</span></span><br><span class="line"><span class="string">&gt;: git branch -d 分支名</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">6.查看远程分支</span></span><br><span class="line"><span class="string">&gt;: git branch -a</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">7.合并分支</span></span><br><span class="line"><span class="string">&gt;: git merge 分支名</span></span><br><span class="line"><span class="string">把dev分支合并到master分支：切换到master分支，执行合并dev分支的命令</span></span><br><span class="line"><span class="string">"""</span></span><br><span class="line"></span><br><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">1）多个开发者都是在一个分支上进行开发，不出意外，该分支一定叫dev（协同开发）</span></span><br><span class="line"><span class="string">2）如果出现一个特殊任务(敏感任务)，与正常业务关系不紧密，甚至可能大的影响正常的dev分支开发，可以依赖dev开一个子分支，进行开发，开发完毕后合并到dev分支，再删除该分支即可</span></span><br><span class="line"><span class="string">3）所有的开发任务都可以在dev分支上进行（除非公司硬性要求不能直接在dev分支开发，只能在dev子分支开发，测试通过后才能合并给dev）</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>





<h2 id="远程git开发"><a href="#远程git开发" class="headerlink" title="远程git开发"></a>远程git开发</h2><h3 id="两种本地与远程仓库同步"><a href="#两种本地与远程仓库同步" class="headerlink" title="两种本地与远程仓库同步"></a>两种本地与远程仓库同步</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">1）你作为项目仓库初始化人员：</span></span><br><span class="line"><span class="string">	线上要创建空仓库 =&gt; 本地初始化好仓库 =&gt; 建立remote链接(remote add) =&gt; 提交本地仓库到远程(push)</span></span><br><span class="line"><span class="string">	</span></span><br><span class="line"><span class="string">2）你作为项目后期开发人员：</span></span><br><span class="line"><span class="string">	远程项目仓库已经创建成功 =&gt; 复制远程仓库到本地(clone) =&gt; 进入仓库就可以进行接下来的开发</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>

<p><img src="https://tva1.sinaimg.cn/large/007S8ZIlgy1ggqvvjqhlmj30lq0fu764.jpg" alt=""></p>
<h3 id="remote源操作"><a href="#remote源操作" class="headerlink" title="remote源操作"></a>remote源操作</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">1）查看仓库已配置的远程源</span></span><br><span class="line"><span class="string">&gt;: git remote</span></span><br><span class="line"><span class="string">&gt;: git remote -v</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">2）查看remote命令帮助文档</span></span><br><span class="line"><span class="string">&gt;: git remote -h</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">3）删除远程源</span></span><br><span class="line"><span class="string">&gt;: git remote remove 源名</span></span><br><span class="line"><span class="string">eg: git remote remove origin</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">4）添加远程源</span></span><br><span class="line"><span class="string">&gt;: git remote add 源名 源地址</span></span><br><span class="line"><span class="string">&gt;: git remote add orgin git@gitee.com:doctor_owen/luffyapi.git</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">5）提交代码到远程源</span></span><br><span class="line"><span class="string">&gt;: git push 源码 分支名</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">6）克隆远程源</span></span><br><span class="line"><span class="string">&gt;: git clone 远程源地址</span></span><br><span class="line"><span class="string">"""</span></span><br><span class="line"></span><br><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">1）通过克隆方式连接远程源，默认远程源名就叫origin；所以主动添加远程源来连接远程仓库，源码也用origin</span></span><br><span class="line"><span class="string">2）本地一个仓库只需要和远程一个源进行同步，所以只需要连接一个远程源，如果还想把本地代码同步给第三个平台，那么可以通过主动添加远程源来连接第三个平台的远程仓库，此时的源码就不能再叫origin了，比如online都可以</span></span><br><span class="line"><span class="string">3）pull和push都可以提供选择不同的源码，和不同的远程仓库交互</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>





<h3 id="采用ssh协议连接远程源"><a href="#采用ssh协议连接远程源" class="headerlink" title="采用ssh协议连接远程源"></a>采用ssh协议连接远程源</h3><h5 id="创建电脑的公钥私钥"><a href="#创建电脑的公钥私钥" class="headerlink" title="创建电脑的公钥私钥"></a>创建电脑的公钥私钥</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">官网：https:&#x2F;&#x2F;gitee.com&#x2F;help&#x2F;articles&#x2F;4181#article-header0</span><br><span class="line"></span><br><span class="line">本机命令，生成公钥：ssh-keygen -t rsa -C &quot;*@*.com&quot;</span><br><span class="line">	邮箱可以任意填写</span><br><span class="line">本机命令，查看公钥：cat ~&#x2F;.ssh&#x2F;id_rsa.pub</span><br><span class="line"></span><br><span class="line">码云线上添加公钥：项目仓库 &#x3D;&gt; 管理 &#x3D;&gt; 部署公钥管理 &#x3D;&gt; 添加公钥 &#x3D;&gt; 添加个人公钥</span><br></pre></td></tr></table></figure>

<h5 id="提交本地代码到远程仓库"><a href="#提交本地代码到远程仓库" class="headerlink" title="提交本地代码到远程仓库"></a>提交本地代码到远程仓库</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">命令：git push origin master</span><br></pre></td></tr></table></figure>

<p><img src="https://tva1.sinaimg.cn/large/007S8ZIlgy1ggqvv9ms1qj30ui0e10tr.jpg" alt=""></p>
<h5 id="如何成为其他码云项目的开发者"><a href="#如何成为其他码云项目的开发者" class="headerlink" title="如何成为其他码云项目的开发者"></a>如何成为其他码云项目的开发者</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">1）生成自己电脑的公钥，配置到自己的码云个人公钥中</span></span><br><span class="line"><span class="string">2）把自己的码云用户名提供给别人，别人添加你成为项目开发者</span></span><br><span class="line"><span class="string">3）自己确认添加，成为开发者，克隆开发项目，进行开发</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>

<h5 id="如何成为公司自建git服务器的开发者"><a href="#如何成为公司自建git服务器的开发者" class="headerlink" title="如何成为公司自建git服务器的开发者"></a>如何成为公司自建git服务器的开发者</h5><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">1）生成自己电脑的公钥(公钥生成一次就可以了)，把它提交给项目管理者</span></span><br><span class="line"><span class="string">2）项目管理者添加你公钥，加入开发者，提供给你项目克隆地址</span></span><br><span class="line"><span class="string">3）克隆开发项目，进行开发</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>





<h3 id="协同开发"><a href="#协同开发" class="headerlink" title="协同开发"></a>协同开发</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">1）作为开发者，第一次同步项目（前台已经是项目开发者了）</span></span><br><span class="line"><span class="string">&gt;: git clone 项目地址</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">2）保证自己本地有dev分支，且与远程仓库版本同步(没有就自己新建)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">3）本地开发的代码，必须add、commit到本地版本库后，才和远程仓库进行交互</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">4）交互顺序：必须 先拉(pull)后提(push)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">5）必须切换到要交互的分支，在与远程同名的分支进行交互，如本地dev与远程dev交互</span></span><br><span class="line"><span class="string">&gt;: git checkout dev</span></span><br><span class="line"><span class="string">&gt;: git add .</span></span><br><span class="line"><span class="string">&gt;: git commit -m '本次提交的信息提示'</span></span><br><span class="line"><span class="string">&gt;: git pull origin dev</span></span><br><span class="line"><span class="string">&gt;: git push origin dev</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>





<h3 id="冲突解决"><a href="#冲突解决" class="headerlink" title="冲突解决"></a>冲突解决</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">1）在远程仓库和本地仓库版本不一致时，拉取远程仓库版本到本地时，两个版本进入融合，可能会出现版本冲突</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">2）定位冲突文件冲突代码，线下沟通冲突代码，整合代码解决冲突</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">3）将解决冲突后的代码重新提交到本地版本库</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">4）再拉去远程仓库，直到没有冲突，提交本地版本库到远程</span></span><br><span class="line"><span class="string">"""</span></span><br><span class="line"></span><br><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD  # 冲突的开始</span></span><br><span class="line"><span class="string"># 自己的代码</span></span><br><span class="line"><span class="string">=======  # 分割线</span></span><br><span class="line"><span class="string"># 别人的代码</span></span><br><span class="line"><span class="string">&gt;&gt;&gt;&gt;&gt;&gt;&gt; b63c408abd05b87fc492d40523240561999dba50  # 冲突的结束(版本)</span></span><br><span class="line"><span class="string">"""</span></span><br><span class="line"></span><br><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">1）删除冲突相关标识：冲突的开始、分割线、冲突的结束(版本)</span></span><br><span class="line"><span class="string">2）线下沟通，根据实际需求完成代码整合</span></span><br><span class="line"><span class="string">3）测试整合后的代码</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">"""</span></span><br><span class="line"></span><br><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">出现冲突的前提：</span></span><br><span class="line"><span class="string">1）不同开发者同时操作了同一文件</span></span><br><span class="line"><span class="string">2）并且在相同行写了代码</span></span><br><span class="line"><span class="string">强调：有业务交际时，版本合并不一定会出现冲突相关的标识，但是可能会带着代码运行崩溃，所有理论上每一次版本合并，都要测试合并后的所有功能(及其之少的情况)</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>





<h3 id="线上分支合并"><a href="#线上分支合并" class="headerlink" title="线上分支合并"></a>线上分支合并</h3><p><img src="https://tva1.sinaimg.cn/large/007S8ZIlgy1ggqvuzs6vtj30xc0e5q4o.jpg" alt=""></p>
<h3 id="远程仓库回滚"><a href="#远程仓库回滚" class="headerlink" title="远程仓库回滚"></a>远程仓库回滚</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">用dev分支举例</span></span><br><span class="line"><span class="string">1）本地切换到远程要回滚的分支对应的本地分支</span></span><br><span class="line"><span class="string">git checkout dev</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">2）回滚本地分支</span></span><br><span class="line"><span class="string">git reset --hard 版本号</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">3）本地版本强行提交给服务器</span></span><br><span class="line"><span class="string">git push origin dev -f</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>















</section>
    <!-- Tags START -->
    
    <!-- Tags END -->
    <!-- NAV START -->
    
  <div class="nav-container">
    <!-- reverse left and right to put prev and next in a more logic postition -->
    
      <a class="nav-left" href="/python/%E8%B7%AF%E9%A3%9E%E9%A1%B9%E7%9B%AE/1-%E9%A1%B9%E7%9B%AE%E5%9F%BA%E7%A1%80/9-luffy%E5%89%8D%E5%8F%B0%E4%B8%BB%E9%A1%B5/">
        <span class="nav-arrow">← </span>
        
          python/路飞项目/1-项目基础/9-luffy前台主页
        
      </a>
    
    
      <a class="nav-right" href="/python/%E8%B7%AF%E9%A3%9E%E9%A1%B9%E7%9B%AE/3-%E7%99%BB%E5%BD%95%E6%B3%A8%E5%86%8C/1-%E7%99%BB%E5%BD%95%E6%B3%A8%E5%86%8C%E9%A1%B5%E9%9D%A2/">
        
          python/路飞项目/3-登录注册/1-登录注册页面
        
        <span class="nav-arrow"> →</span>
      </a>
    
  </div>

    <!-- NAV END -->
    <!-- 打赏 START -->
    
      <div class="money-like">
        <div class="reward-btn">
          赏
          <span class="money-code">
            <span class="alipay-code">
              <div class="code-image"></div>
              <b>使用支付宝打赏</b>
            </span>
            <span class="wechat-code">
              <div class="code-image"></div>
              <b>使用微信打赏</b>
            </span>
          </span>
        </div>
        <p class="notice">点击上方按钮,请我喝杯咖啡！</p>
      </div>
    
    <!-- 打赏 END -->
    <!-- 二维码 START -->
    
      <div class="qrcode">
        <canvas id="share-qrcode"></canvas>
        <p class="notice">扫描二维码，分享此文章</p>
      </div>
    
    <!-- 二维码 END -->
    
      <!-- Gitment START -->
      <div id="comments"></div>
      <!-- Gitment END -->
    
  </article>
  <!-- Article END -->
  <!-- Catalog START -->
  
    <aside class="catalog-container">
  <div class="toc-main">
  <!-- 不蒜子统计 -->
    <strong class="toc-title">目录</strong>
    
      <ol class="toc-nav"><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#版本控制器"><span class="toc-nav-text">版本控制器</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#git"><span class="toc-nav-text">git</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-4"><a class="toc-nav-link" href="#简介"><span class="toc-nav-text">简介</span></a></li><li class="toc-nav-item toc-nav-level-4"><a class="toc-nav-link" href="#git与svn比较"><span class="toc-nav-text">git与svn比较</span></a></li><li class="toc-nav-item toc-nav-level-4"><a class="toc-nav-link" href="#git的工作流程"><span class="toc-nav-text">git的工作流程</span></a></li><li class="toc-nav-item toc-nav-level-4"><a class="toc-nav-link" href="#版本库间的通信"><span class="toc-nav-text">版本库间的通信</span></a></li><li class="toc-nav-item toc-nav-level-4"><a class="toc-nav-link" href="#git分支管理"><span class="toc-nav-text">git分支管理</span></a></li></ol></li></ol></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#git使用"><span class="toc-nav-text">git使用</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#流程（核心总结）"><span class="toc-nav-text">流程（核心总结）</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-4"><a class="toc-nav-link" href="#安装"><span class="toc-nav-text">安装</span></a></li><li class="toc-nav-item toc-nav-level-4"><a class="toc-nav-link" href="#基础命令"><span class="toc-nav-text">基础命令</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-5"><a class="toc-nav-link" href="#将已有的文件夹-初始化为git仓库"><span class="toc-nav-text">将已有的文件夹 - 初始化为git仓库</span></a></li><li class="toc-nav-item toc-nav-level-5"><a class="toc-nav-link" href="#在指定目录下-初始化git仓库"><span class="toc-nav-text">在指定目录下 - 初始化git仓库</span></a></li><li class="toc-nav-item toc-nav-level-5"><a class="toc-nav-link" href="#在仓库目录终端下-设置全局用户"><span class="toc-nav-text">在仓库目录终端下 - 设置全局用户</span></a></li><li class="toc-nav-item toc-nav-level-5"><a class="toc-nav-link" href="#在仓库目录终端下-设置局部用户"><span class="toc-nav-text">在仓库目录终端下 - 设置局部用户</span></a></li><li class="toc-nav-item toc-nav-level-5"><a class="toc-nav-link" href="#查看仓库状态"><span class="toc-nav-text">查看仓库状态</span></a></li><li class="toc-nav-item toc-nav-level-5"><a class="toc-nav-link" href="#工作区操作"><span class="toc-nav-text">工作区操作</span></a></li><li class="toc-nav-item toc-nav-level-5"><a class="toc-nav-link" href="#撤销工作区操作：改、删（了解）"><span class="toc-nav-text">撤销工作区操作：改、删（了解）</span></a></li><li class="toc-nav-item toc-nav-level-5"><a class="toc-nav-link" href="#工作区内容提交到暂存区"><span class="toc-nav-text">工作区内容提交到暂存区</span></a></li><li class="toc-nav-item toc-nav-level-5"><a class="toc-nav-link" href="#撤销暂存区提交：add的逆运算（很少使用）"><span class="toc-nav-text">撤销暂存区提交：add的逆运算（很少使用）</span></a></li><li class="toc-nav-item toc-nav-level-5"><a class="toc-nav-link" href="#提交暂存区内容到版本库"><span class="toc-nav-text">提交暂存区内容到版本库</span></a></li><li class="toc-nav-item toc-nav-level-5"><a class="toc-nav-link" href="#撤销版本库提交：commit的逆运算"><span class="toc-nav-text">撤销版本库提交：commit的逆运算</span></a></li></ol></li></ol></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#过滤文件"><span class="toc-nav-text">过滤文件</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#多分支开发"><span class="toc-nav-text">多分支开发</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-5"><a class="toc-nav-link" href="#分支操作"><span class="toc-nav-text">分支操作</span></a></li></ol></li></ol></li></ol></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#远程git开发"><span class="toc-nav-text">远程git开发</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#两种本地与远程仓库同步"><span class="toc-nav-text">两种本地与远程仓库同步</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#remote源操作"><span class="toc-nav-text">remote源操作</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#采用ssh协议连接远程源"><span class="toc-nav-text">采用ssh协议连接远程源</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-5"><a class="toc-nav-link" href="#创建电脑的公钥私钥"><span class="toc-nav-text">创建电脑的公钥私钥</span></a></li><li class="toc-nav-item toc-nav-level-5"><a class="toc-nav-link" href="#提交本地代码到远程仓库"><span class="toc-nav-text">提交本地代码到远程仓库</span></a></li><li class="toc-nav-item toc-nav-level-5"><a class="toc-nav-link" href="#如何成为其他码云项目的开发者"><span class="toc-nav-text">如何成为其他码云项目的开发者</span></a></li><li class="toc-nav-item toc-nav-level-5"><a class="toc-nav-link" href="#如何成为公司自建git服务器的开发者"><span class="toc-nav-text">如何成为公司自建git服务器的开发者</span></a></li></ol></li></ol></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#协同开发"><span class="toc-nav-text">协同开发</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#冲突解决"><span class="toc-nav-text">冲突解决</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#线上分支合并"><span class="toc-nav-text">线上分支合并</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#远程仓库回滚"><span class="toc-nav-text">远程仓库回滚</span></a></li></ol></li></ol>
    
  </div>
</aside>
  
  <!-- Catalog END -->
</main>

<script>
  (function () {
    var url = 'http://www.liuqingzheng.top/python/路飞项目/2-git笔记/1-git/';
    var banner = ''
    if (banner !== '' && banner !== 'undefined' && banner !== 'null') {
      $('#article-banner').css({
        'background-image': 'url(' + banner + ')'
      })
    } else {
      $('#article-banner').geopattern(url)
    }
    $('.header').removeClass('fixed-header')

    // error image
    $(".markdown-content img").on('error', function() {
      $(this).attr('src', 'http://file.muyutech.com/error-img.png')
      $(this).css({
        'cursor': 'default'
      })
    })

    // zoom image
    $(".markdown-content img").on('click', function() {
      var src = $(this).attr('src')
      if (src !== 'http://file.muyutech.com/error-img.png') {
        var imageW = $(this).width()
        var imageH = $(this).height()

        var zoom = ($(window).width() * 0.95 / imageW).toFixed(2)
        zoom = zoom < 1 ? 1 : zoom
        zoom = zoom > 2 ? 2 : zoom
        var transY = (($(window).height() - imageH) / 2).toFixed(2)

        $('body').append('<div class="image-view-wrap"><div class="image-view-inner"><img src="'+ src +'" /></div></div>')
        $('.image-view-wrap').addClass('wrap-active')
        $('.image-view-wrap img').css({
          'width': `${imageW}`,
          'transform': `translate3d(0, ${transY}px, 0) scale3d(${zoom}, ${zoom}, 1)`
        })
        $('html').css('overflow', 'hidden')

        $('.image-view-wrap').on('click', function() {
          $(this).remove()
          $('html').attr('style', '')
        })
      }
    })
  })();
</script>


  <script>
    var qr = new QRious({
      element: document.getElementById('share-qrcode'),
      value: document.location.href
    });
  </script>



  <script>
    var gitmentConfig = "liuqingzheng";
    if (gitmentConfig !== 'undefined') {
      var gitment = new Gitment({
        id: "python/路飞项目/2-git笔记/1-git",
        owner: "liuqingzheng",
        repo: "FuckBlog",
        oauth: {
          client_id: "32a4076431cf39d0ecea",
          client_secret: "94484bd79b3346a949acb2fda3c8a76ce16990c6"
        },
        theme: {
          render(state, instance) {
            const container = document.createElement('div')
            container.lang = "en-US"
            container.className = 'gitment-container gitment-root-container'
            container.appendChild(instance.renderHeader(state, instance))
            container.appendChild(instance.renderEditor(state, instance))
            container.appendChild(instance.renderComments(state, instance))
            container.appendChild(instance.renderFooter(state, instance))
            return container;
          }
        }
      })
      gitment.render(document.getElementById('comments'))
    }
  </script>




    <div class="scroll-top">
  <span class="arrow-icon"></span>
</div>
    <footer class="app-footer">
<!-- 不蒜子统计 -->
<span id="busuanzi_container_site_pv">
     本站总访问量<span id="busuanzi_value_site_pv"></span>次
</span>
<span class="post-meta-divider">|</span>
<span id="busuanzi_container_site_uv" style='display:none'>
     本站访客数<span id="busuanzi_value_site_uv"></span>人
</span>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>



  <p class="copyright">
    &copy; 2021 | Proudly powered by <a href="https://www.cnblogs.com/xiaoyuanqujing" target="_blank">小猿取经</a>
    <br>
    Theme by <a href="https://www.cnblogs.com/xiaoyuanqujing" target="_blank" rel="noopener">小猿取经</a>
  </p>
</footer>

<script>
  function async(u, c) {
    var d = document, t = 'script',
      o = d.createElement(t),
      s = d.getElementsByTagName(t)[0];
    o.src = u;
    if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
    s.parentNode.insertBefore(o, s);
  }
</script>
<script>
  async("//cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.6/fastclick.min.js", function(){
    FastClick.attach(document.body);
  })
</script>

<script>
  var hasLine = 'true';
  async("//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js", function(){
    $('figure pre').each(function(i, block) {
      var figure = $(this).parents('figure');
      if (hasLine === 'false') {
        figure.find('.gutter').hide();
      }
      var lang = figure.attr('class').split(' ')[1] || 'code';
      var codeHtml = $(this).html();
      var codeTag = document.createElement('code');
      codeTag.className = lang;
      codeTag.innerHTML = codeHtml;
      $(this).attr('class', '').empty().html(codeTag);
      figure.attr('data-lang', lang.toUpperCase());
      hljs.highlightBlock(block);
    });
  })
</script>





<!-- Baidu Tongji -->

<script>
    var _baId = 'c5fd96eee1193585be191f318c3fa725';
    // Originial
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?" + _baId;
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
</script>


<script src="/js/script.js"></script>


<script src="/js/search.js"></script>


<script src="/js/load.js"></script>



  <span class="local-search local-search-google local-search-plugin" style="right: 50px;top: 70px;;position:absolute;z-index:2;">
      <input type="search" placeholder="站内搜索" id="local-search-input" class="local-search-input-cls" style="">
      <div id="local-search-result" class="local-search-result-cls"></div>
  </span>


  </body>
</html>